import 'package:flutter/material.dart';
import 'package:flutter_frpc/flutter_frpc.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  var addressController = TextEditingController();
  var portController = TextEditingController();
  var passwordController = TextEditingController();
  @override
  void initState() {
    super.initState();
    addressController.text = "117.50.162.33";
    portController.text = "7000";
    passwordController.text = "password";
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(),
        body: Center(
            child: Column(
          children: [
            TextField(
              controller: addressController,
              decoration: const InputDecoration(),
            ),
            TextField(
              controller: portController,
              decoration: const InputDecoration(),
            ),
            TextField(
              controller: passwordController,
              decoration: const InputDecoration(),
            ),
            ElevatedButton(
                onPressed: () {
                  FlutterFrpc.init(
                      address: addressController.text,
                      port: portController.text,
                      password: passwordController.text);
                },
                child: const Text("init rpc")),
            ElevatedButton(
                onPressed: () {
                  FlutterFrpc.connect();
                },
                child: const Text("connect")),
            ElevatedButton(
                onPressed: () {
                  FlutterFrpc.disconnect();
                },
                child: const Text("disconnect")),
          ],
        )),
      ),
    );
  }
}
